﻿Imports System.Activities
Imports System.Activities.Presentation.PropertyEditing
Imports System.Windows
Imports Microsoft.VisualBasic.Activities

Public Class FilepathPropertyEditor
    Inherits DialogPropertyValueEditor

    Public Sub New()
        Dim base As New DesignerBase
        Dim editorTemplate = base.Resources("ArgumentFilepathPropertyEditor")
        Me.InlineEditorTemplate = CType(editorTemplate, DataTemplate)
    End Sub

    Public Overrides Sub ShowDialog(propertyValue As System.Activities.Presentation.PropertyEditing.PropertyValue, commandSource As System.Windows.IInputElement)
        MyBase.ShowDialog(propertyValue, commandSource)

        Dim dlg As New Microsoft.Win32.OpenFileDialog With {
            .AddExtension = True,
            .CheckFileExists = False,
            .Multiselect = False,
            .Filter = My.Resources.OpenFileFilter}

        If dlg.ShowDialog Then
            propertyValue.Value = New InArgument(Of String)(New VisualBasicValue(Of String)(dlg.FileName))
        End If

    End Sub

End Class
